<template>
  <div class="blurb" ref="scrollBox" @touchstart="touchstart" @touchmove="myScroll" @scroll="getScroll">
    <div class="scrollBox">
      <h1>{{ $t("views.index.blurb.title") }}</h1>
      <div class="topText">
        <div>
          <p class="title">{{ $t("views.index.blurb.definition") }}:</p>
          <p>{{ $t("views.index.blurb.definition-text") }}</p>
        </div>
        <div>
          <p class="title">{{ $t("views.index.blurb.definition") }}:</p>
          <p>{{ $t("views.index.blurb.definition-text1") }}</p>
        </div>
      </div>
      <hr />
      <p class="bottomText">
        <span>{{ $t("views.index.blurb.text") }}</span><br />
        <br />
        <span>{{ $t("views.index.blurb.text1") }}</span><br />
        <span>{{ $t("views.index.blurb.text2") }}</span><br />
        <span>{{ $t("views.index.blurb.text3") }}</span><br />
        <span>{{ $t("views.index.blurb.text4") }}</span><br />
        <br />
        <span>{{ $t("views.index.blurb.text5") }}</span><br />
        <span>{{ $t("views.index.blurb.text6") }}</span><br />
        <span>{{ $t("views.index.blurb.text7") }}</span><br />
        <span>{{ $t("views.index.blurb.text8") }}</span><br />
      </p>
    </div>
  </div>
</template>

<script>
let scrollAll = 0;
let scrollTop = 0;
let clientY = 0;
let isScroll = true;
export default {
  data() {
    return {
      isStop: true,
    }
  },
  created() {
    this.$bus.$on('setIsStop', () => {
      this.isStop = true;

      this.$nextTick(() => {
        isScroll = (this.$refs.scrollBox.scrollHeight - this.$refs.scrollBox.offsetHeight) == 0 ? false : true
        if (!isScroll) {
          this.isStop = false
        } else {
          this.$refs.scrollBox.scrollTop = 10;
        }
      })
    })
  },
  methods: {
    getScroll(e) {
      scrollAll = e.target.scrollHeight - e.target.clientHeight;
      scrollTop = e.target.scrollTop
      if (scrollTop >= scrollAll - 10 || scrollTop <= 0) {
        this.isStop = false
      } else {
        this.isStop = true
      }
    },
    touchstart(event) {
      clientY = event.touches[0].clientY;
    },
    myScroll(event) {
      if (isScroll) {
        if (scrollTop <= 0 && event.touches[0].clientY < clientY) {
          this.$refs.scrollBox.scrollTop = scrollTop + 10;
          this.isStop = true
        }
        if (scrollTop >= scrollAll - 10 && event.touches[0].clientY > clientY) {
          this.$refs.scrollBox.scrollTop = scrollTop - 10;
          this.isStop = true
        }
      }
      if (this.isStop) {
        event.stopPropagation();
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.blurb {
  width: 100%;
  height: 100%;
  background: url("@/assets/image/indexBgImage/indexBgImage_blurb.jpg") no-repeat;
  background-size: cover;
  overflow-y: scroll;
  box-sizing: border-box;
  padding: 125px 30px;
}

.scrollBox {
  width: 100%; // height: 100%;
  // overflow-y: scroll;
}

h1 {
  font-weight: bold;
  font-size: 60px;
  color: #ffffff;
  line-height: 58px;
  margin-top: 124px;
  margin-bottom: 34px;
}

.topText {
  div {
    display: flex;
    font-weight: bold;
    font-size: 24px;
    color: #ffffff;

    .title {
      white-space: nowrap;
    }
  }
}

.bottomText {
  font-weight: bold;
  font-size: 24px;
  color: #ffffff;
}

hr {
  width: 100%;
  border: none;
  border-top: 1px dotted #ffffff;
  opacity: 0.1;
  margin: 56px 0 40px;
}
</style>
